package com.tarena.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.smartstruts.action.Action;
import org.smartstruts.action.ActionForm;

import com.tarena.bo.EmpDao;
import com.tarena.bo.UserDao;
import com.tarena.vo.Emp;
import com.tarena.vo.User;

/**
 * 
 * 显示员工列表
 * 
 * @author Wangpeihu
 * @since 05/01/2010
 * @Team [Never give up]
 */
public class EmpListAction extends Action {
	private EmpDao ed = new EmpDao();
	private UserDao ud = new UserDao();

	@Override
	public String execute(ActionForm form, HttpServletRequest request,
			HttpServletResponse response) {
		try {
			request.setCharacterEncoding("utf-8");
			HttpSession session = request.getSession();
			List<Emp> empList = ed.findAllEmp();
			
			/**将员工记录放在request里面*/
			request.setAttribute("empList", empList);
			
			User user1 = (User) session.getAttribute("user_key");
			User user2 = ud.getUser(user1);
			request.setAttribute("user_detail", user2);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		return "success";
	}

}
